package com.mate.cloud.lottery;

import com.mate.cloud.lottery.constants.LotteryExceptionCodeEnum;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import java.io.IOException;
import java.util.Properties;

@SpringBootTest
class SpringBootLotteryRedisApplicationTests {

    @Test
    void contextLoads() {
    }

    /**
     * 4. 方式四
     *
     * Resource resource = new ClassPathResource(path)
     * @throws IOException
     */
    @Test
    public void test2() throws IOException {
        Resource resource = new ClassPathResource("messages/messages.properties");
        Properties properties = PropertiesLoaderUtils.loadProperties(resource);
        properties.list(System.out);
        System.out.println("==============================================");
        String property = properties.getProperty(String.valueOf(LotteryExceptionCodeEnum.REQUEST_PARAM_NOT_VALID.getCode()));
        System.out.println("property = " + property);
    }
}
